package controllers

import (
	"git.oschina.net/fanbuchi/timemaker/models"
	"github.com/astaxie/beego"
)

type ErrorController struct {
	beego.Controller
}

// 404、401、403、500、503

func (this *ErrorController) Error404() {
	status := models.ObjectStatus{models.PathError, "404 page not found!"}
	this.Data[dataformat] = status
	this.ServeJson()
}

func (this *ErrorController) Error403() {
	status := models.ObjectStatus{models.PathError, "403 error"}
	this.Data[dataformat] = status
	this.ServeJson()
}

func (this *ErrorController) Error401() {
	status := models.ObjectStatus{models.PathError, "401 error"}
	this.Data[dataformat] = status
	this.ServeJson()
}

func (this *ErrorController) Error500() {
	status := models.ObjectStatus{models.ServerError, "500 error"}
	this.Data[dataformat] = status
	this.ServeJson()
}

func (this *ErrorController) Error501() {
	status := models.ObjectStatus{models.ServerError, "501 error"}
	this.Data[dataformat] = status
	this.ServeJson()
}

func (this *ErrorController) ErrorDb() {
	status := models.ObjectStatus{models.DBError, "database is now down"}
	this.Data[dataformat] = status
	this.ServeJson()
}
